package com.lokyiu.tutorial.java.ninexninetable;

import java.util.ArrayList;
import java.util.List;

public class NineNineTable {
	int x=9,y=9;
	
	public NineNineTable(){
	}
	
	public NineNineTable(int X,int Y){
		this.x=X;
		this.y=Y;
	}
	

	public int getX(){
		return x;
	}
	
	public int getY(){
		return y;
	}
	
	public List<String> calculate(){
		List<String> result = new ArrayList<String>();
		int i,j;
		for(i = 1 ; i <= x ; i++){
			for(j = 1 ; j<= y ; j++){
				result.add(j + "x" + i + "=" + i*j + "");
			}
		}					
		return result;
	}
	
	public void output(){
		int i = 1;
		for(String out : calculate()){
			System.out.print(out + " ");
			if(i>=y){
				i=0;
				System.out.println("");
			}
			i++;
		}
	}
	
}